﻿
namespace ThingsGateway.Foundation
{
    /// <summary>
    /// 包含了各种解析规则，数据信息提取规则<br />
    /// </summary>
    public interface INetMessage : IRequestInfo
    {
        /// <summary>
        /// 消息头字节<br />
        /// </summary>
        byte[] HeadBytes { get; }

        /// <summary>
        /// 消息头的指令长度，第一次接受数据的长度<br />
        /// </summary>
        int ProtocolHeadBytesLength { get; }
        /// <summary>
        /// 实体数据长度<br />
        /// </summary>
        int BodyLength { get; set; }
        /// <summary>
        /// 发送的字节信息<br />
        /// </summary>
        byte[] SendBytes { get; set; }
        /// <summary>
        /// 接收的字节信息
        /// </summary>
        byte[] ReceivedBytes { get; set; }
        /// <summary>
        /// 解析后的字节数据
        /// </summary>
        byte[] Content { get; set; }

        /// <summary>
        /// 检查头子节的合法性,并赋值<see cref="BodyLength"/><br />
        /// </summary>
        /// <param name="head">接收的头子节</param>
        /// <returns>是否成功的结果</returns>
        bool CheckHeadBytesLegal(byte[] head);

        public bool IsSuccess { get; }
        /// <summary>
        /// 返回代码
        /// </summary>
        ResultCode ResultCode { get; set; }
        /// <summary>
        /// 消息
        /// </summary>
        string Message { get; set; }
    }
}